#ifndef UTILS_H
#define UTILS_H
#include <point.h>
#include <QVector>
#include <NumCpp.hpp>
#include <ctime>
#include <exception>
#include <vector>

using std::vector;

class Utils
{
private:
    double maxMarkov;
    double beta;
    double nMarkov;
    double tInit;
    double tFinal;
    double alpha;
    int nCities;
    double tNow;
    double valueNow;
    double valueBest;
    //double runTime;
    nc::NdArray<int> tourNow;
    nc::NdArray<int> tourBest;
    vector<double> recordBest;
    vector<double> recordNow;
    nc::NdArray<Point> coordinates;
    nc::NdArray<double> distMat;
public:
    Utils(QVector<Point> &points,double tInit,double tFinal,double alpha);
    void runTSP();
    QVector<int> getTourBest();
    QString getTourBestStr();
    //double getRunTime();
    double getBestValue();
private:
    nc::NdArray<double> getDistMat();
    void init();
    double calcTourMile();
    double calcTourMile(nc::NdArray<int> tour,int n);
    void mutateInvE(nc::NdArray<int> &,double &);
    void mutateMoveE(nc::NdArray<int> &,double &);
    void mutateSwapE(nc::NdArray<int> &,double &);
    template<typename T> inline void swap(T &a,T &b){auto t=a;a=b;b=t;}
};

#endif // UTILS_H
